﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Sànnhàở</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="Stylesheet" href="css/style.css" type="text/css" />
</head>
<body>
    <div class="wrapper">
    <?php require_once("top.php");?>
        <div class="body">
            <div class="cat-left">
                <div class="title-3">
                    Danh mục
                </div>
                <div style="line-height: 20px; padding: 5px">
                    <?php require_once("connection/connect.php");
				$rs = mysql_query("select * from categories");
				while($d = mysql_fetch_array($rs)){
                	echo "<a href= category.php?id=".$d["cat_id"].">".$d["name"]."</a><br/>";
				}?>
                </div>
            </div>
            <div class="cat-right">
                <table class="list-header">
                    <tr>
                        <td style="width: 160px">
                            Hình
                        </td>
                        <td style="width: 145px">
                            Chi tiết
                        </td>
                        <td style="width: 145px">
                            Người đăng
                        </td>
                        <td style="width: 145px">
                            Địa điểm
                        </td>
                        <td>
                            Ngày
                        </td>
                    </tr>
                </table>
                <!-- item -->
                <?php
				if(isset($_GET['id'])){
				$rs1 = mysql_query("
				SELECT username, users.user_id, products.product_id as p1, products.name as n1,  area, livingroom, bedroom, bathroom, products.user_id, products.address, products.cat_id, datecreate, pro_images.product_id as p2, pro_images.name as n2, price, prices.product_id
				FROM users, products, pro_images, prices 
				WHERE products.product_id = pro_images.product_id 
					AND products.product_id = prices.product_id
					AND users.user_id = products.user_id and cat_id = ".$_GET['id']);
					if($nrow = mysql_num_rows($rs1)==0){
						echo "Không có sản phẩm";
					}else{
				while($d = mysql_fetch_array($rs1)){
				?>
                <table cellpadding="5px" style="line-height: 20px; border-bottom: 1px solid #d6d6d6;
                    padding-bottom: 10px; width: 100%; margin-top: 10px">
                    <tr>
                        <td style="width: 150px; border-right: 1px solid #ff9900; vertical-align: top">
                            <img alt="" border="0" src="images/<?php echo $d["n2"];?>" width="140px" />
                        </td>
                        <td style="width: 135px; border-right: 1px solid #ff9900; vertical-align: top">
                            <span style="color: #dd4400; font-weight: bold"><?php echo $d["n1"];?>
                            </span><span class="text-1">$:</span> <?php echo number_format($d["price"],0);?><br />
                            <span class="text-1">Diện tích:</span> <?php echo number_format($d["area"],0);?> m2<br />
                            <span class="text-1">Phòng khách:</span> <?php echo $d["livingroom"];?><br />
                            <span class="text-1">Phòng ngủ:</span> <?php echo $d["bedroom"];?><br />
                            <span class="text-1">Phòng tắm:</span><?php echo $d["bathroom"];?>                      </td>
                        <td style="width: 135px; border-right: 1px solid #ff9900; vertical-align: top">
                            <?php echo $d["username"];?></td>
                        <td style="width: 135px; border-right: 1px solid #ff9900; vertical-align: top"><?php echo $d["address"];?>                        </td>
                        <td style="vertical-align: top">
                            <?php echo date(('d/m/Y'), strtotime($d["datecreate"]));?>

                        </td>
                    </tr>
                </table>
                <?php }
					}
				}else{
					echo"Vui lòng chọn danh mục";
				}?>
                <!-- /item -->
          </div>
            <div class="vide">
            </div>
        </div>
    </div>
    <?php require_once("footer.php");?>
</body>
</html>
